﻿using System;
using System.Web.Http;
using Common;
using IBll;
using MainService.Controllers.Extend;
using RequestModel.Mq;
using ResponseModel.Common;

namespace MainService.Controllers
{
    /// <summary>
    /// MQ控制器
    /// </summary>
    public class MqController : BaseApiController
    {
        public IMqBll MqBll { get; set; }

        /// <summary>
        /// 发送消息
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public ResultModel SendMessage(MqMessage mqMessage)
        {
            ResultModel resultModel = new ResultModel();

            try
            {
                if (MqBll.ProduceMessage(mqMessage))
                {
                    resultModel.Pass = true;
                    resultModel.Msg = "发送消息成功";
                }
                else
                {
                    resultModel.Msg = "发送消息成功失败";
                }
            }
            catch (Exception ex)
            {
                LogHelper.Error("报错：" + ex.Message);
                resultModel.Msg = "报错：" + ex.Message;
            }

            return resultModel;
        }
    }
}
